package com.huluobo.a2109mvpimdemo.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.huluobo.a2109mvpimdemo.R;
import com.hyphenate.chat.EMGroupInfo;

import java.util.List;

/**
 * Created by LC on 2023/11/17.
 */
public class AddGroupAdapter extends BaseQuickAdapter<EMGroupInfo, BaseViewHolder> {
    public AddGroupAdapter(@Nullable List<EMGroupInfo> data) {
        super(R.layout.item_add_group, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, EMGroupInfo emGroupInfo) {
        baseViewHolder.setText(R.id.item_addGroup_tv, emGroupInfo.getGroupName());
        baseViewHolder.findView(R.id.item_addGroup_btn).setOnClickListener(v -> {
            onAddClick.addClick(emGroupInfo.getGroupId());
        });
    }

    public interface OnAddClick {
        void addClick(String groupId);
    }

    private OnAddClick onAddClick;

    public void setOnAddClick(OnAddClick onAddClick) {
        this.onAddClick = onAddClick;
    }
}
